package com.example.trans.service;

import com.example.trans.mapper.LogInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

@Service
public class LogService {

    @Autowired
    LogInfoMapper logInfoMapper;


    @Transactional(propagation = Propagation.NESTED)
    public Integer register(String userName, String op) {

        Integer result = logInfoMapper.insert(userName,op);
        try {
            int a = 10/0;
        } catch (Exception e) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return result;
    }


}
